<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ include file="index.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<!-- <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" /> -->

<!-- <title>主页</title>
    <meta name="keywords" content="耶回收">
    <meta name="description" content="耶回收"> -->

<link href="<%=basePath%>lib/webuploader/0.1.5/webuploader.css"
	rel="stylesheet" type="text/css" />
</head>

<body>
	<!--_表格--开始-->
	<section class="Hui-article-box" style="overflow: auto"> <nav
		class="breadcrumb"> <i class="Hui-iconfont">&#xe67f;</i> 首页 <span
		class="c-gray en">&gt;</span> 回收评论管理 <span class="c-gray en">&gt;</span> 所有评论  
		<a class="btn btn-success radius r"
		style="line-height: 1.6em; margin-top: 3px"
		href="javascript:location.replace('backEvaluate?pageNum=1&gtimeq=&gtimeh=&phone=')"
		title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	
	<div class="Hui-article">
		<article class="cl pd-20">
		<div class="text-c">
			<form action="backEvaluate" method="post">
				评论时间：<input type="date" class="input-text" style="width: 150px"
					placeholder="" value="${gb.gtimeq }" id="" name="gtimeq">-
				<input type="date" class="input-text" style="width: 150px"
					placeholder="" value="${gb.gtimeh }" id="" name="gtimeh">
				用户电话：<input type="text" class="input-text" style="width: 250px"
					placeholder="输入手机" onblur="phoneyz(this.id)" value="${gb.phone }" id="phone" name="phone">
				<i class="Hui-iconfont">&#xe665;</i><input type="submit"
					class="btn btn-success" value="搜评论" id="" name="">
			</form>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			 <shiro:hasPermission name="order"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a></shiro:hasPermission>
			 <span class="r">共有数据：<strong>${pageinfo.total }</strong>条</span>
		</div>
		<table class="table table-border table-bordered table-bg">
			<thead>
				<tr>
					<th scope="col" colspan="7">评论列表</th>
				</tr>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="60">序号</th>
					<th width="80">phone</th>
					<th width="100">评论信息</th>
					<th width="80">评论时间</th>
					<th width="80">评论商品</th>
					<th width="60">操作</th>
				</tr>
			</thead>
			<tbody id="tb">
				<c:forEach items="${pageinfo.list }" var="list" varStatus="status">
					<tr class="text-c">
						<td ><input type="checkbox" value="${list.id }" name=""></td>
						<td>${status.count }</td>
						<td>${list.phone }</td>
						<td>${list.gcontent }</td>
						<td><fmt:formatDate value="${list.gtime }"
								pattern="yyyy-MM-dd HH:mm:ss" /></td>
						<td>${list.bname }</td>
						<td class="td-manage">
							<a title="删除" href="javascript:;"
							onclick="backEvaluate_del(${list.id })" class="ml-5"
							style="text-decoration: none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
					</tr>
				</c:forEach>
			</tbody>
			<thead>
				<tr>
					<th colspan="7"><p>第${pageinfo.pageNum}页
							共${pageinfo.pages}页</p> <a
						href="backEvaluate?pageNum=1&gtimeq=${gb.gtimeq }&gtimeh=${gb.gtimeh }&phone=${gb.phone }">首页</a>
						<c:choose>
							<c:when test="${pageinfo.pageNum==1||pageinfo.pageNum==0 }">
								<a href="#">上一页</a>
							</c:when>
							<c:otherwise>
								<a
									href="backEvaluate?pageNum=${pageinfo.prePage}&gtimeq=${gb.gtimeq }&gtimeh=${gb.gtimeh }&phone=${gb.phone }">上一页</a>
							</c:otherwise>
						</c:choose> <c:choose>
							<c:when test="${pageinfo.pageNum==pageinfo.pages }">
								<a href="#">下一页</a>
							</c:when>
							<c:otherwise>
								<a
									href="backEvaluate?pageNum=${pageinfo.nextPage}&gtimeq=${gb.gtimeq }&gtimeh=${gb.gtimeh }&phone=${gb.phone }">下一页</a>
							</c:otherwise>
						</c:choose> <a
						href="backEvaluate?pageNum=${pageinfo.pages}&gtimeq=${gb.gtimeq }&gtimeh=${gb.gtimeh }&phone=${gb.phone }">尾页</a>
					</th>
				</tr>
			</thead>
		</table>
		</article>
	</div>
	</section>

</body>

<script type="text/javascript">
	/*评论-删除*/
    function backEvaluate_del(id){
        layer.confirm('确认要删除吗？',{ btn: ["确定","取消"] },function(index){
            $.ajax({
                type: 'POST',
                url: 'backEvaluateDel',
                data:{id:id},
                dataType: 'json',
                success: function(val){
                	layer.close(index);
                	if(val==1){
                		alert("删除成功!");
                	};
                	if(val==2){
                		alert("删除失败！");
                	};
                	
                	window.location.href = window.location.href;                	
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
	
	
    /*电话验证*/
    function phoneyz(id){
    	var v=$("#"+id).val();
    	if(v.indexOf('"')==0){
    		$("#"+id).val(null)
    		alert('输入不能包含"！');
    	}
    }
    
    
    /*批量删除*/
    function datadel(){
 	  console.log("-----进入批量删除的方法------");
 	  var tds = new Array();
        //获取所有的tr标签元素集合
 	   tds=document.getElementById("tb").getElementsByTagName("tr");
 		  var td_s = new Array();
 		 
 		  for(var i=0;i<tds.length;i++){
 		  var tdc =tds[i].getElementsByTagName("td")[0].getElementsByTagName("input")[0];
 		  var tdcheck =$(tdc);
 		  console.log(tdcheck.is(":checked"));
 		  if(tdcheck.is(":checked")){
 		    //如果td被选中 则td的id值放入数组中
 			td_s.push(tdcheck.val());
 		    
 		 } 
 		  } 
 	   //判断是否有被选中删除的记录 
 	   if(td_s.length>0){
 		  console.log(td_s);
 		   //发出批量删除ajax 删除请求
 		   layer.confirm('确认要删除吗？',{ btn: ["确定","取消"] },function(index){
 	           $.ajax({
 	               type: 'POST',
 	               url: 'deletebpl',
 	               data:{"td_s":td_s},
 	               dataType: 'json',
 	               success: function(val){
 	               	layer.close(index);
 	               layer.msg("删除成功",{icon:1,time:2000});
 	               	window.location.href = window.location.href;                	
 	               },
 	               error:function(data) {
 	                   console.log(data.msg);
 	               },
 	           });
 	       });
 	   }else{ 
 		   
 		   layer.msg("请选择要删除的数据！",{time:2000});
 		 
 	   }
 	   
    }
</script>
</html>